import concurrent.futures
import subprocess
import time


def run_command(command):
    # 输出当前时间戳和执行的指令
    print(f"{time.strftime('%H:%M:%S')} - Running command: {command}")
    subprocess.run(command, shell=True)


def main():
    commands = [
        "sleep 1 && echo 'Command 1'",
        "sleep 1 && echo 'Command 2'",
        "sleep 1 && echo 'Command 3'"
    ]

    with concurrent.futures.ProcessPoolExecutor() as executor:
        for command in commands:
            executor.submit(run_command, command)

    # # 等待所有命令执行完成
    # for future in concurrent.futures.as_completed(futures):
    #     future.result()


# 运行主函数
main()
